package com.hmall.common.config;

import com.hmall.common.interceptors.UserInfoInterceptors;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Author:Cammy.Wu
 * Date:2024-05-26
 * Description:
 */

@Configuration
@ConditionalOnClass(DispatcherServlet.class)
// 只要是微服务，都有SpringMvc，有SpringMvc就一定有SpringMvc的核心api就是DispatcherServlet.class
public class MvcConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new UserInfoInterceptors());
    }
}
